#pragma once

//#include "Tile.h"
#include <string>

//////////////////////////////////////////////////////////////////////////

//#include "../SGD Wrappers/CSGD_TextureManager.h"
//#include "../TinyXml/tinyxml.h"
#include "SGD Wrappers\CSGD_TextureManager.h"
#include "tinyxml\tinyxml.h"


//////////////////////////////////////////////////////////////////////////
class Tile;

class TileManager
{
	Tile *** gameGrid;
	int sizeX;
	int sizeY;
	int tileBmpID;
	int bmpCellWidth;
	int bmpCellHeight;
	int tileSizeX;
	int tileSizeY;
	std::string fileName;
	int posX;
	int posY;
	float scale;
	std::string tileSetBmpFile;

	static TileManager * pInstance;

	TileManager(void);
	~TileManager(void);
	TileManager(const TileManager&);
	TileManager * operator=(const TileManager&);

public:
	
	void Update(float elapsedTime);
	void Render();
	void CreateGrid(std::string file);
	void DestroyGrid();

	static TileManager * GetInstance();
	static void DeleteInstance();

	Tile* GetTile(int x, int y) {return gameGrid[x][y];}
	int GetSizeX()
	{
		return sizeX;
	}
	void SetSizeX(int x)
	{
		sizeX = x;
	}
	int GetSizeY()
	{
		return sizeY;
	}
	void SetSizeY(int y)
	{
		sizeY = y;
	}

	int GetTileBmpID()
	{
		return tileBmpID;
	}

	void SetTileBmpID(int id)
	{
		tileBmpID = id;
	}

	int GetTileSizeX()
	{
		return tileSizeX;
	}

	void SetTileSizeX(int x)
	{
		tileSizeX = x;
	}

	int GetTileSizeY()
	{
		return tileSizeY;
	}

	void SetTileSizeY(int y)
	{
		tileSizeY = y;
	}

	int GetPosX()
	{
		return this->posX;
	}

	void SetPosX(int x)
	{
		this->posX = x;
	}

	int GetPosY()
	{
		return this->posY;
	}

	void SetPosY(int y)
	{
		this->posY = y;
	}

	float GetScale()
	{
		return scale;
	}

	void SetScale(float s)
	{
		scale = s;
	}

	RECT CreateTileSourceRect(int cellID);

	Tile * ReturnHilightedTile(int stateType);

	const char * GetTileSetFile()
	{
		return this->tileSetBmpFile.c_str();
	}

	void ResetHighlights();

};

